####
# 
# File: sfxCompilerChecks
# 
# (C) Copyright 2019. All rights reserved.
# 
# Author: ShenYongchen (shenyczz@163.com)
# 
###############################################################################
# 
if(SFX_MACRO_MESSAGE_SWITCH)
  message(STATUS "sfx runing - ${CMAKE_CURRENT_LIST_FILE}")
endif()

# 
# ID: GNU
# Minimum compiler version check: GCC >= 4.8
# 
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
    CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
  message(FATAL_ERROR "GCC 4.8 or later is required.")
endif ()

# 
# ID: Clang
# Minimum compiler version check: LLVM Clang >= 3.3
# 
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
    CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
  message(FATAL_ERROR "LLVM Clang 3.3 or later is required.")
endif ()

# 
# ID: AppleClang
# Minimum compiler version check: Apple Clang >= 5.0 (Xcode 5.0)
# 
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND
    CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
  message(FATAL_ERROR "Apple Clang 5.0 or later is required.")
endif ()

# 
# ID: MSVC
# Minimum compiler version check: Microsoft C/C++ >= 19.0 (aka VS 2015)
# 
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
    CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0)
  message(FATAL_ERROR "Microsoft Visual Studio 2015 or later is required.")
endif ()

# 
# ID: Intel
# Minimum compiler version check: Intel C++ (ICC) >= 14
# 
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND
    CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14.0)
  message(FATAL_ERROR "Intel C++ (ICC) 14.0 or later is required.")
endif ()

# 
# Make sure we have C++11 enabled.
# 
if(NOT SFX_IGNORE_CMAKE_CXX11_CHECKS)
  set(CMAKE_CXX_STANDARD 11)
  set(CMAKE_CXX_STANDARD_REQUIRED True)
  set(CMAKE_CXX_EXTENSIONS False)
endif()

# 
# Make sure we have C++14 enabled.
# 
if(NOT SFX_IGNORE_CMAKE_CXX14_CHECKS)
  set(CMAKE_CXX_STANDARD 14)
  set(CMAKE_CXX_STANDARD_REQUIRED True)
  set(CMAKE_CXX_EXTENSIONS False)
endif()

# 
# Make sure we have C++17 enabled.
# 
check_cxx_compiler_flag("${std_cxx17}" _sfx_cxx_17_flag_supported)
if(NOT SFX_IGNORE_CMAKE_CXX17_CHECKS AND _sfx_cxx_17_flag_supported)
  set(CMAKE_CXX_STANDARD 17)
  set(CMAKE_CXX_STANDARD_REQUIRED True)
  set(CMAKE_CXX_EXTENSIONS False)
endif()

# 
# Make sure we have C++20 enabled.
# 
check_cxx_compiler_flag("${std_cxx20}" _sfx_cxx_20_flag_supported)
if(NOT SFX_IGNORE_CMAKE_CXX20_CHECKS AND _sfx_cxx_20_flag_supported)
  set(CMAKE_CXX_STANDARD 20)
  set(CMAKE_CXX_STANDARD_REQUIRED True)
  set(CMAKE_CXX_EXTENSIONS False)
endif()

# 
# CMAKE_CXX_STANDARD
# 
message(STATUS "Compiling with C++ standard: ${CMAKE_CXX_STANDARD} - [sfxCompilerChecke] ")



# 
# }}@@@
# 

